#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

QT_BEGIN_NAMESPACE
class QMdiArea;
class QMdiSubWindow;
class QMenu;
class QAction;
class QToolbar;
class QSignalMapper;
QT_END_NAMESPACE

class AISpeechAgent;
class AISAudioRender;

#define NAME_ORGANIZATION "cn.aiseminar"
#define NAME_APPLICATION "AISProduct"

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

protected:
    void closeEvent(QCloseEvent *);

private slots:
    void updateMenus();

    void newFile();
    void openFile();
    void saveFile();
    void startSpeaking();
    void stopSpeaking();
    void speechSetting();

    void setActiveSubWindow(QWidget *subWindow);

private:
    void initCentralWidget();
    void initAction();
    void initMenuBar();

    void initSpeechAgent();
    void uninitSpeechAgent();

    void initAudioRender();
    void uninitAudioRender();

    void saveSetting();
    void loadSetting();

    QMdiSubWindow *findMdiChild(const QString &filePath);
private:
    QMdiArea *mdiArea;
    QSignalMapper *signalMapper;

    AISpeechAgent *speechAgent;
    AISAudioRender *audioRender;

    QMenu *fileMenu;
    QMenu *speechMenu;

    QAction *newFileAct;
    QAction *openFileAct;
    QAction *saveFileAct;
    QAction *startSpeakingAct;
    QAction *stopSpeakingAct;
    QAction *speechSettingAct;

    QString recentUsedFolder;
};

#endif // MAINWINDOW_H
